﻿CREATE VIEW [acms].[Topic_View]
AS 
	SELECT 
		a.Id, 
		a.TopicGroupId,
		b.Name as TopicGroupName,
		b.Path as TopicGroupPath,
		a.Name, 
		a.Sequence,
		a.Created,
		(Select Count(Id) From TopicFiles Where TopicId = a.Id and Deleted = 0) as FileCount,
		a.VersionId
	FROM [Topics] a
		Inner Join [TopicGroup_View] b On a.TopicGroupId = b.Id
	Where Deleted = 0
;